
import {observable,action,computed} from 'mobx'
import {TreeData} from "../../../../api/work/menu/MenuApi";


class Store {
    @observable record = {};

    @observable records = [];

    @observable keyMap = {};

    @observable nodeDes = "";

    @observable type = "";

    @action fetchRecords = () => {
        TreeData().then(response => {
            if (response.data.code === 200){
                this.records = response.data.list;
                this.keyMap = response.data.listMap;
            }
        })
    };

   @action getNodeDes = () => {
        try {
            if (this.type === "plus"){
                this.nodeDes = "添加<" + this.keyMap[this.record.pid]["title"] + ">的下级"
            }else if (this.type === "edit"){
                this.nodeDes = "编辑<" + this.record.title + ">"
            }else if (this.type === "top"){
                this.nodeDes = "创建顶级菜单"
            }else {
                this.nodeDes = ""
            }

            return this.nodeDes;
        }catch (e) {
            return "";
        }
   }
}

export default new Store();
